﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Sbook.Page
{
    public partial class DoiMatKhau : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Form["OldPass"] != null&&Data.Mysession.isLogin==true&&Request.Form["NewPass"]!=null)
                {
                    string NewPass = Request.Form["NewPass"];
                    string OldPass = Request.Form["OldPass"];
                    string User = Data.Mysession.Session.Username;
                    if (OldPass == Business.UserService.User_GetByAll().FindAll(u => u.Username == User)[0].Pass)
                    {
                        Data.UserInfo obj = Data.Mysession.Session;
                        obj.Pass = NewPass;
                        Business.UserService.User_Update(obj);
                        Response.Write("1");

                    }
                    else
                    {
                       
                        Response.Write("0");
                    }
                }
            }
        }
    }
}